package Tathy;

import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;




import GameEngine.GameEngine;
import GameEngine.GameObject2D;
	
public class Tathy extends GameObject2D {
	Mapa mapa;
	//FireBlue fireB;
	BufferedImage tathy;
	BufferedImage magia1;
	BufferedImage chao;
	public int contSpriteH = 0;
	public int contSpriteW = 0;
	int ContS, magia=0;
	boolean M1=false;
	int contM;
	
	public Tathy() {
		super("");
		//fireB = new FireBlue();
		try{
			//tathy = ImageIO.read(getClass().getResource("tathy2.png"));
			tathy = ImageIO.read(getClass().getResource("ozzy.png"));
			magia1 = ImageIO.read(getClass().getResource("M1.gif"));
			//chao = ImageIO.read(getClass().getResource("chao.jpg"));
		}catch (IOException e) {
			e.printStackTrace();
		}
		
	}


	public void paint(Graphics g) {
		//g.drawImage(chao, 0, 0, null);
		g.drawImage(tathy.getSubimage(tathy.getWidth()/4*contSpriteW, tathy.getHeight()/4*contSpriteH, 
				tathy.getWidth()/4,tathy.getHeight()/4),340,230,null);
		
		/*if(M1==true){
			contM++;
			if (contM>5&& contM <10){
				magia=1;
			}
			if (contM>10&& contM <15){
				magia=2;
			}
			if (contM>15){
				M1=false;
				magia=0;
				contM=0;
			}
		g.drawImage(magia1.getSubimage(magia1.getWidth()/3*magia, magia1.getHeight()/1*0, 
				magia1.getWidth()/3,magia1.getHeight()),posH+50,posV+10,null);
		g.drawImage(magia1.getSubimage(magia1.getWidth()/3*magia, magia1.getHeight()/1*0, 
				magia1.getWidth()/3,magia1.getHeight()),posH-54,posV+10,null);
		g.drawImage(magia1.getSubimage(magia1.getWidth()/3*magia, magia1.getHeight()/1*0, 
				magia1.getWidth()/3,magia1.getHeight()),posH,posV+50,null);
	
		}*/
		//g.drawImage(magia1.getSubimage(192/3*1, 76, 192/3, 76),400, 400, null);
		
	}


	public void updateKeyEvent(KeyEvent keyevent) {
		//if (keyevent.getKeyChar() == '1'
			//	&& keyevent.getID() == KeyEvent.KEY_PRESSED){
		/*if(GameEngine.umPressed){
			M1=true;
			System.out.println("q pressionado");
		}*/
		if (GameEngine.rightKeyPressed) {
			ContS++;
			if(ContS>=5){
			contSpriteH = 2;
			contSpriteW ++;
			
			ContS=0;
			if(contSpriteW>=4){
				contSpriteW=0;
			}
			}
		}
			if(GameEngine.leftKeyPressed){
				ContS++;
				if(ContS>=5){
				contSpriteH = 1;
				contSpriteW--;
				
				ContS=0;
				if (contSpriteW<=0){
					contSpriteW=3;
				}
			}
			}
			if(GameEngine.upKeyPressed){
				ContS++;
				if(ContS>=5){
				contSpriteH = 3;
				contSpriteW--;
				ContS=0;
				if (contSpriteW<=0){
					contSpriteW=3;
				}
			}
			}
			if(GameEngine.downKeyPressed){
				ContS++;
				if(ContS>=5){
				contSpriteH = 0;
				contSpriteW--;
				
				ContS=0;
				if (contSpriteW<=0){
					contSpriteW=3;
				}
			}
			}
		
		
	}

	public void updateMouseEvent(MouseEvent mouseevent) {
	
		
	}

}
